<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>声明提升（实例1）</title>
</head>

<body>
    <p id="demo"></p>
    <script>
        x = 5;  // 变量 x 设置为 5
        elem = document.getElementById("demo"); // 查找元素 
        elem.innerHTML = x;
    </script>
</body>

</html>